<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<!--引入头文件-->
<head th:include="aside :: head"></head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    <div class="container-fluid">
      <div class="row">
        <h2>课程列表</h2>
        <div class="col-md-10">
          <table style="text-align: center" class="table table-striped table-bordered table-hover">
            <thead>
               <tr style="height: 60px">
                <th style="text-align: center">序号</th>
                <th style="text-align: center">课程名</th>
                <th style="text-align: center">教室</th>
                <th style="text-align: center">老师</th>
                <th style="text-align: center">最大学生数</th>
                 <th class="text-center" width="100">操作</th>
              </tr>
            </thead>
            <tbody>
              <tr style="height: 60px" th:each="book,index:${bookList}">
                <td th:text="${index.count}"></td>
                <td th:text="${book.name}"></td>
                <td th:text="${book.classroom}"></td>
                <td th:text="${book.teacher}"></td>
                <td th:text="${book.maxnumber}"></td>
                <td class="text-center">
                  <a th:href="@{/toUpdateBook(id=${book.id})}" class="btn btn-default btn-xs">编辑</a>
                  <a th:onclick="'javascript:del(\''+${book.id}+'\');'" class="btn btn-danger btn-xs">删除</a>
                </td>
                <script type="text/javascript">
                    function del(id){
                        var message = confirm("您确定要删除该数据吗？");
                        if (message == true){
                            window.location.href="/deleteBook?id="+id;
                            return true;
                        }else{
                            return false;
                        }
                    }
                </script>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="main">
          <div class="row">
            <div class="col-md-10">
              <h2>添加课程</h2>
              <form th:action="@{/insertBook}" method="post" >
                <div class="form-group">
                  <label for="name" style="color: #f854ec">课程名</label>
                  <input id="name" class="form-control" style="height: 50px;width: 400px"  name="name" type="text" >
                </div>
                <div class="form-group">
                  <label for="classroom" style="color: #f854ec">教室</label>
                  <input id="classroom" class="form-control" style="height: 50px;width: 400px"  name="classroom" type="text" >
                </div>
                <div class="form-group">
                  <label for="teacher" style="color: #f854ec">老师</label>
                  <input id="teacher" class="form-control" style="height: 50px;width: 400px"  name="teacher" type="text" >
                </div>
                <div class="form-group">
                  <label for="maxnumber" style="color: #f854ec">最大学生数</label>
                  <input id="maxnumber" class="form-control" style="height: 50px;width: 400px"  name="maxnumber" type="text" >
                </div>
                <div class="form-group">
                  <button class="btn btn-primary" type="submit">添加</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!--引入边缘部分-->
  <div class="aside" th:include="aside :: aside"></div>
  <script>NProgress.done()</script>
</body>
</html>
